package com.yilin.tms.capital.commons.strategy.operation;

import com.yilin.tms.capital.commons.strategy.tools.*;
import com.yilin.tms.capital.service.*;
import com.yilin.tms.core.entity.capital.TradeRecord;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;

/**
 *  银行操作工厂
 *  */
@Repository
public class BankOperationFactory {

    @Resource
    private ICmbcService cmbcService;
    @Resource
    private IPabService pabService;
    @Resource
    private IAlipayService alipayService;
    @Resource
    private IWeCartService weCartService;
    @Resource
    private IPsbService psbService;

    public  BankOperation createBankOperation(TradeRecord.BankType bankType, TradeRecord.PayType payType) {
        if(bankType!=null&&payType== TradeRecord.PayType.bankPay){
            switch (bankType) {
                case cmbcBankPay:
                    return new CmbcBankOperation(cmbcService);
                case pabBankPay:
                    return new PabBankOperation(pabService);
                case psbBankPay:
                    return new PsbBankOperation(psbService);
                // 添加更多银行类型的操作
                default:
                    throw new IllegalArgumentException("没有找到对应银行");
            }
        }else if(payType== TradeRecord.PayType.wxPay){
            return new WeChatOperation(weCartService);
        }else if(payType== TradeRecord.PayType.alipay){
            return new AliPayOperation(alipayService);
        }else {
            throw new IllegalArgumentException("没有找到对应支付方式");  
        }

    }
}
